#include "PrologException.h"


PrologException::PrologException(void)
{
}

PrologException::PrologException(ErrorMessage mess, std::string name, int row)
{
	this->_mess = mess;
	this->_name = name;
	this->_row = row;
}


PrologException::~PrologException(void)
{
}

std::string PrologException::generationErrorMessage()
{
	std::string str = "";
	char* buf = new char[10];
	switch (this->_mess)
	{
	case UNKNOWN_IDENTIFIER:
		str += "Unknow identifier: ";
		break;
	case ARGUMENTS_TYPE:
		str += "Types do not match: ";
		break;
	case COUNT_ARGUMENTS:
		str += "The discrepancy between the number of arguments: ";
		break;
	case NO_PARENTHESIS_OPEN:
		str += "The absence of the opening bracket: ";
		break;
	case INVALID_SYMBOL:
		str += "Invalid symbol: ";
		break;
	case NO_POINT:
		str += "No point: ";
		break;
	case NO_GOAL:
		str += "No section goal!!!";
		return str;
	case NO_PREDICATE_IN_GOAL:
		str += "Program can not run without a goal!";
		return str;
	case DEFICIENCY_CLAUSES_FOR_PREDICATES:
		str += "Not all predicates are described in clauses!";
		return str;
	case MORE_GOAL:
		str += "The program should be one goal. Extra goal: ";
		break;
	case NO_SECTION:
		str += "No section: ";
		break;
	case DOUBLE_SECTION:
		str += "Section duplicated: ";
		break;
	case NO_COMMA:
		str += "No comma:";
		break;
	}
	if (_name.compare("") != 0)
	{
		str += _name;
		str += ", ";
	}
	str += "line ";
	str += _itoa(this->_row, buf, 10);
	str += ".";
	return str;
}